<template>
	<view>
	<view v-if="texttype!='addminus'" @click="(name == 'sys_modifylog'&&dataobj.value!=undefined) ?openlog():''" 
		:style="{'color':(name == 'sys_modifylog'&&dataobj.value!=undefined) ?'#4CCFFF':'#888', 'background-color':dataobj.editable?'#f8f8f8':'#fff'}" 
		style="padding: 2px 18px;color:#888; display: flex;flex-direction: row;justify-content: space-between;">
		
		<view style="display: flex;align-items: center;color: #444;" :style="{'fontSize':clientType=='pda'?'20px':'14px'}">{{dataobj.colText}} 
			<view v-if="dataobj.tag_isNotEmpty" style="color: #F55C23;font-size: 6px;" class="iconfont icon-jiufuqianbaoicon14"> </view>
		</view>
		
		<view style="text-align: right;max-width: 60vw;word-break: break-all;overflow: hidden;" :style="{'fontSize':clientType=='pda'?'20px':'14px'}"
			v-if="(dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly) && dataobj.value != undefined && isaddedit">
			<input :placeholder="dataobj.placeholder" :style="{'background-color':(dataobj.tabsequence!=0) ?'#d0d0d0':'#fff'}" style="padding-right: 10px;"  @focus="inputfocus" @blur="inputblur($event)" placeholder-style="font-size:14px;" :disabled="!((dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly))" :value="dataobj.value" :type="dataobj.coltype"/> 
		</view>
		<view style="text-align: right;max-width: 60vw;word-break: break-all;overflow: hidden;" :style="{'fontSize':clientType=='pda'?'20px':'14px'}" v-else-if="dataobj.value == undefined && isaddedit">
			<input :placeholder="dataobj.placeholder" :style="{'background-color':(dataobj.tabsequence!=0) ?'#d0d0d0':'#fff'}"
					@blur="inputblur($event)" @focus="inputfocus" placeholder-style="font-size:14px;"  :disabled="!((dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly))" :value="dataobj.initial" :type="dataobj.coltype"/> 
		</view>
		<view style="text-align: right;max-width: 60vw;word-break: break-all;overflow: hidden;" :style="{'fontSize':clientType=='pda'?'20px':'14px'}" v-else>
			{{dataobj.value==undefined?'':dataobj.value}}
		</view>
	</view>
	<view v-else :style="{'background-color':!dataobj.editable?'#fff':'#f8f8f8'}"  style="color: #444;font-size: 14px; display: flex;flex-direction: row;justify-content: space-between;">
		<view style="display: flex;align-items: center;">{{dataobj.colText}} <view v-if="dataobj.isnotnull" style="color: #F55C23;font-size: 6px;padding: 13px 0;" class="iconfont icon-jiufuqianbaoicon14"> </view></view>
		<view style="color: #aaa;display: flex;flex-direction: row;width: 60vw;align-items: center;">
			<view v-if="dataobj.editable">
				<input :placeholder="dataobj.placeholder" @blur="inputblur($event)" placeholder-style="color:#aaa;font-size:14px;" style="padding: 8px 0; text-align:middle;display: flex;justify-content: center;" :disabled="!dataobj.editable" :value="dataobj.coldisplay" :type="dataobj.coltype"/>
			</view>
			<view v-else style="padding: 8px 0;">
				{{dataobj.coldisplay}}
			</view>
			<view v-if="dataobj.coltype=='digit' && dataobj.editable"  style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin: -2px 0;">
				<view @click="layerclick('minus')" style="display: flex;padding: 13px 0; justify-content: center; width: 40px;border-left: 1px solid #f0f0f0;border-right: 1px solid #f0f0f0;color: #00B6F6;" class="iconfont icon-jianqu"></view> 
				<view @click="layerclick('plus')" style="display: flex;padding: 13px 0; justify-content: center; width: 40px;border-right: 1px solid #f0f0f0;color: #00B6F6;" class="iconfont icon-jia"></view> 
			</view>
			<view v-if="dataobj.coltype=='textscan' && dataobj.editable"  style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin: -2px 0;">
				<view  style="display: flex;padding: 13px 0; justify-content: center; width: 40px;border-left: 1px solid #f8f8f8;border-right: 1px solid #f8f8f8;color: #f8f8f8;" class="iconfont icon-jianqu"></view>
				<view @click="layerclick('scan')"  style="display: flex;padding: 13px 0; justify-content: center; width: 40px;border-left: 1px solid #f0f0f0;border-right: 1px solid #f0f0f0;color: #00B6F6;" class="iconfont icon-saomiao"></view>
			</view>
		</view>
	</view>
	</view>
</template>


<script>
	var util = require("../../utils/util.js");
	export default {
		props:{
			dataobj:{
				type:Object
			},
			listblockindex:{
				type:Number
			},
			listitemindex:{
				type:Number
			},
			listindex:{
				type:Number
			},
			texttype:{
				type:String
			},
			jsonoptions:{
				type:Object
			},
			name:{
				type:String
			},
			divArea:{
				type:String
			},
			bigdatalist:{
				type:Array
			},
			pagename:{
				type:String
			},
			isaddedit:{
				type:Boolean
			},
			
			clientType:{
				type:String,
				default(){
					return ""
				}
			}
		},
		
		mounted:function(){
			var that = this
		},
		
		methods:{
			
			openlog(){
				var that = this
				var item = that.bigdatalist[0].data
				var options = that.jsonoptions
				var modid = options.modid
				var menuid = options.menuid
				var conditions = {}
				var keyvalue = ''
				for(var i=0; i<item.length; i++){
					if(item[i].style.key){
						keyvalue += item[i].style.value+','
					}
				}
				if(keyvalue.length >0){
					keyvalue = keyvalue.substring(0, keyvalue.length-1)
				}
				conditions['pkvalue'] = keyvalue
				uni.navigateTo({url:'/pages/infolist/infolist?templatename=appsj_log&pagename=appsj_log&menuid=&modid='+modid+'&divArea=&opttype=&menuname=更新日志&conditions='+JSON.stringify(conditions)})
				
			},
			
			inputfocus(){
				// #ifdef APP-PLUS
				uni.$emit("focuslist", this.divArea, this.listindex, this.listblockindex, this.listitemindex, this.dataobj,this.pagename)
				// #endif
			},
			
			inputblur(event){
				var that = this
				console.log(event)
				var inputvalue = event.detail.value
				var colType = that.dataobj.colType
				console.log(inputvalue)
				if((colType=='digit' || colType=='number' || colType=='long') ){
					if( inputvalue==''){
						inputvalue = 0
					}else{
						inputvalue = parseInt(inputvalue)
					}
				}
				that.dataobj.value = inputvalue
				that.dataobj.colValue = inputvalue
				that.dataobj.coldisplay = inputvalue
				that.dataobj.ismodified = true
				console.log('updatelist')
				uni.$emit("updatelist", that.divArea, that.listindex, that.listblockindex, that.listitemindex, that.dataobj,this.pagename)
			},
			
			
			
			layerclick(type,index){
				var that = this
				that.indexgooditem = index
				var detailvalue = that.dataobj.value
				var detailvalue1 = that.dataobj.coldisplay
				if(detailvalue==''){
					detailvalue = 0
					detailvalue1 = 0
				}
				if(type=='minus' && parseFloat(detailvalue)>0){
					that.dataobj.value = parseFloat(detailvalue) - 1
					that.dataobj.coldisplay = parseFloat(detailvalue1) - 1
				}else if(type=='plus'){
					that.dataobj.value = parseFloat(detailvalue) + 1
					that.dataobj.coldisplay = parseFloat(detailvalue1) + 1
				}else if(type == 'scan'){
					uni.scanCode({
					    onlyFromCamera: true,
					    success: function (res) {
							var scancode = res.result
							that.dataobj.value = scancode
							that.dataobj.coldisplay = scancode
					    }
					});
				}
				that.datalist[that.index2].style = that.dataobj
				that.$emit('changeData',that.index3,that.index2,that.dataobj,that.datalist)
			},
		}
	}
</script>

<style>
</style>
